/**
 * Project: apollo-base-tools
 * 
 * File Created at 2017年8月16日
 * 
 * Copyright 2015-2016 dx.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DongXue software Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with dx.com.
 */
package org.apollo.base.tools.ui;

/** 
* @ClassName: FileTableModel 
* @Description: TODO(这里用一句话描述这个类的作用) 
* @author wuzhenfang(wzfbj2008@163.com)
* @date 2017年8月16日 下午7:57:33 
* @version V1.0 
*/
import java.io.File;

import javax.swing.filechooser.FileSystemView;
import javax.swing.table.DefaultTableModel;

/**
 * Created by Administrator on 2016/3/29.
 */
public class FileTableModel extends DefaultTableModel {

	private static final long serialVersionUID = 1L;
	private static String[] tableHeader = {"名称", "修改日期", "类型", "大小"};
    private FileSystemView fileSystemView = FileSystemView.getFileSystemView();
    public FileTableModel(Object[][] objects){
        super(objects, tableHeader);
    }

    @Override
    public boolean isCellEditable(int row, int column) {
        return false;
    }


    @Override
    public Object getValueAt(int row, int column) {
        File file = (File) super.getValueAt(row, column);
        if (column == 0){
            return file;
        } else if (column == 1){
            return file.lastModified();
        } else if (column == 2) {
            return fileSystemView.getSystemTypeDescription(file);
        } else if (column == 3){
            return file.length();
        }
        return super.getValueAt(row, column);
    }
}
